package com.sfeir.tv.client.ui.container;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtfavideo.client.core.FAVideo;
import com.sfeir.tv.client.mvc.framework.AppEvent;
import com.sfeir.tv.client.mvc.framework.Model;
import com.sfeir.tv.client.mvc.framework.View;
import com.sfeir.tv.client.mvc.framework.impl.gwt.GWTHorizontalPanel;

public class ContainerView extends GWTHorizontalPanel {
	Label description;
	private ScrollPanel scrollPanel = new ScrollPanel();
	FAVideo flvViewer;

	/**
	 * Do not use this method as it is a base component
	 */
	public ContainerView() {
		this("container-" + System.currentTimeMillis());
	}
	
	public ContainerView(String id) {
		super(id);
		setSize("100%", "100%");
		AbsolutePanel leftContent = new AbsolutePanel();
		add(leftContent);
		leftContent.setSize("100%", "100%");
		
		scrollPanel.setSize("100%", "500px");
		add(scrollPanel);
		
		flvViewer = new FAVideo("flvViewer");
		flvViewer.setSize("443", "369");
		flvViewer.setVolume(80);
		leftContent.add(flvViewer, 0, 0);
		
		description = new Label();
		leftContent.add(description, 0, 400);
		description.setWidth("440px");
	}
	
	public void refreshView(Model model) {
	}

	public void fireEvent(int eventType) {
	}
	public void addList(Widget widget) {
		scrollPanel.add(widget);
		putChildInMap(((View)widget).getId(), (View) widget);
	}

	public void setVideoID(String videoID) {
	    flvViewer.loadMovie(videoID);
	    flvViewer.setVolume(80);
	    flvViewer.setAutoPlay(true);
	}
	
	public void setDescription(String description) {
		this.description.setText(description);
	}
	
    public void onGWTBrowserEvent( Event event )
    {
        if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
            fireEvent( AppEvent.CLICK_EVENT );
        } 
    }

	   // ==============================================================
    public void dispose()
    {
        // TODO Auto-generated method stub
        
    }

    public boolean isDisposed()
    {
        // TODO Auto-generated method stub
        return false;
    }

    public void doInit()
    {
        // TODO Auto-generated method stub
        
    }

    public void init()
    {
        // TODO Auto-generated method stub
        
    }

    public void post()
    {
        // TODO Auto-generated method stub
        
    }

    public void pre()
    {
        // TODO Auto-generated method stub
        
    }

}
